summaryrefslogtreecommitdiffstats
path: root/src/pages/releases/[version].tsx
blob: dde1e3b7195386f7e9c1e83d393d945b87512b93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { Page, PipelineStageError } from "corvos";

import { strapiLoader } from "$/deps/strapi.tsx";
import { releaseStrapiSchema } from "$/schemas/releases.ts";
import { SplitLayout } from "$/ui/base/SplitLayout.tsx";
import { ActionButton } from "$/ui/objects/ActionButton.tsx";
import { Body } from "$/ui/objects/Body.tsx";
import { Button } from "$/ui/objects/Button.tsx";
import { Card } from "$/ui/objects/Card.tsx";
import { CardBody } from "$/ui/objects/CardBody.tsx";
import { Heading } from "$/ui/objects/Heading.tsx";
import { Icon } from "$/ui/objects/Icon.tsx";
import site from "@/corvos.config.ts";

export const pages = site.$.pageGenerator(async function* () {
	for await (const item of strapiLoader.loadCollection("corvos-releases", releaseStrapiSchema, {
		"populate[0]": "files",
		"sort[0]": "date:desc",
		"sort[1]": "version:desc",
	})) {
		if (item instanceof PipelineStageError) {
			yield item;
			continue;
		}

		yield new Page(".strapi", item.notes ?? [], {
			...item,
			title: `Corvos ${item.version}`,
			type: "release" as const,
		});
	}
});

export const template = site.$.template({ type: "release" }, (page, pages) => {
	const query = site.$.query(pages);

	const feed = query.type(".rss").match({ type: "releases" }).one();

	return (
		<SplitLayout
			page={page}
			content={
				<>
					<Heading as="h1" class="u-mbs-0 p-name" display level="xl">
						Release notes
					</Heading>

					<Body class="e-content">{{ __html: page.content }}</Body>
				</>
			}
			header-end={
				<div class="l-media__block">
					<ActionButton
						align-block
						class="u-mbs-0"
						href={feed.url}
						icon={<Icon icon="rss-simple" variant="bold" />}
						level="quiet"
						pill
						title="RSS Feed"
					/>
				</div>
			}
		>
			<Card horizontal>
				<CardBody class="u-pie-0">
					<Icon icon="package" variant="fill" class="u-fs-300" />
				</CardBody>

				<CardBody main>
					<ul class="u-c-mute">
						<li>
							<small>
								<time datetime={page.data.date.toISOString()}>
									{page.data.date.toLocaleDateString(undefined, {
										day: "numeric",
										month: "long",
										year: "numeric",
									})}
								</time>
							</small>
						</li>
					</ul>

					<Heading class="u-mbs-50" as="h1" level="xl">
						{page.data.title}
					</Heading>
				</CardBody>
			</Card>

			<Button
				class="u-d-block u-mbs-200"
				href={site.$.url(`/pkg/corvos@${page.data.version}/`)}
				variant="primary"
			>
				View source
			</Button>
		</SplitLayout>
	);
});